//
//  LeftViewController.m
//  Fragrance
//
//  Created by yinzhongyuan on 15/5/29.
//  Copyright (c) 2015年 dllo. All rights reserved.
//

#import "LeftViewController.h"

@interface LeftViewController ()

@end

@implementation LeftViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    [self.view setBackgroundColor:[UIColor yellowColor]];
    
    UIImage *imageBg = [UIImage imageNamed:@"beijingtu1"];
    UIImageView *imageV = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height)];
    imageV.image = imageBg;
    [self.view addSubview:imageV];
    
    [imageV release];
    
    
    
    UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
    button.frame = CGRectMake(0, 110, 100, 50);
    [button setTitle:@"查看收藏" forState:UIControlStateNormal];
    [button setTitleColor:[UIColor orangeColor] forState:UIControlStateNormal];
    [self.view addSubview:button];
    [button addTarget:self action:@selector(lookThrough:) forControlEvents:UIControlEventTouchUpInside];
    
    UIButton *buttonClear = [UIButton buttonWithType:UIButtonTypeCustom];
    buttonClear.frame = CGRectMake(0, 160, 100, 50);
    [buttonClear setTitle:@"清除缓存" forState:UIControlStateNormal];
    [buttonClear setTitleColor:[UIColor orangeColor] forState:UIControlStateNormal];
    [self.view addSubview:buttonClear];
    [buttonClear addTarget:self action:@selector(Clear) forControlEvents:UIControlEventTouchUpInside];
    
    
    UIButton *button1 = [UIButton buttonWithType:UIButtonTypeCustom];
    button1.frame = CGRectMake(0, 210, 100, 50);
    [button1 setTitle:@"清除收藏" forState:UIControlStateNormal];
    [button1 setTitleColor:[UIColor orangeColor] forState:UIControlStateNormal];
    [self.view addSubview:button1];
    [button1 addTarget:self action:@selector(clearSave) forControlEvents:UIControlEventTouchUpInside];
    
    
    UIButton *button2 = [UIButton buttonWithType:UIButtonTypeCustom];
    button2.frame = CGRectMake(0, 260, 100, 50);
    [button2 setTitle:@"关于我们" forState:UIControlStateNormal];
    [button2 setTitleColor:[UIColor orangeColor] forState:UIControlStateNormal];
    [self.view addSubview:button2];
    [button2 addTarget:self action:@selector(aboutUs) forControlEvents:UIControlEventTouchUpInside];
    
    
    
    
}


- (void)aboutUs
{
    UsViewController *us = [[[UsViewController alloc] init] autorelease];
    us.modalTransitionStyle = UIModalTransitionStylePartialCurl;
[self presentViewController:us animated:YES completion:^{
    
}];
}


//清除所有收藏
- (void)clearSave

{
    
    [DataBaseManager deleteValue];
    UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"友情提示" message:@"您已清除所有收藏" delegate:self cancelButtonTitle:nil otherButtonTitles:@"确定", nil];

    [alert show];
    [alert release];
}


//查看收藏
- (void)lookThrough:(NSIndexPath *)indexPath
{
    self.arr = [NSMutableArray array];
    self.arr = [DataBaseManager selectData];

    
    if (self.arr.count == 0) {
        UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"友情提示" message:@"您没有收藏" delegate:self cancelButtonTitle:@"取消" otherButtonTitles:@"确定", nil];
       
        [alert show];
        [alert release];
    }else{
        NSLog(@"请查看");
        
        
        SaveViewController *save = [[[SaveViewController alloc] init] autorelease];
        save.arr = self.arr;
        [self.navigationController pushViewController:save animated:YES];
       
       
    }
    
}
//清除内存
- (void)Clear

{
        NSInteger size = [[SDImageCache sharedImageCache]getSize];
        NSLog(@"%ld", size);
    
    AlartViewController *alart = [[AlartViewController alloc] init];
    alart.expendAbleAlartViewDelegate = self;
    __block UIViewController *weakVC = self;

    [alart showView:weakVC];
    
    
    
}



- (void)negativeButtonAction
{
    NSLog(@"negative Action");
}
- (void)positiveButtonAction
{
    NSLog(@"positive Action");
    
    
    [[SDImageCache sharedImageCache]clearDisk];
}
- (void)closeButtonAction
{
    NSLog(@"close Action");
}




- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
